<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>主页</title>
  <link rel="stylesheet" href="index.css">
  <script type="text/javascript" src="index.js"></script>
</head>

<body>
  <div class="dashboard">
    <nav class="nav-links">
      <a href="index.html">主页</a>
      <a href="http://192.168.51.65:8080/?action=stream">监控</a>
      <a href="2.html">煽情</a>
    </nav>

    <div class="sensor-sdata">
      <h1>码到成功组智能家居控制中心</h1>
      <p>当前时间: <span id="current-time"></span></p>
      <div class="data-grid">
        <div class="data-card">
          <p>温度: <span id="temp">--°C</span></p>
        </div>
        <div class="data-card">
          <p>湿度: <span id="humi">--%</span></p>
        </div>
        <div class="data-card">
          <p>光照强度: <span id="light">--%</span></p>
        </div>
        <div class="data-card">
          <p>烟雾浓度: <span id="smoke">--%</span></p>
        </div>
      </div>

      <div class="controls">
        <form>
          <!-- STM32设备 -->
          <div class="control-group" data-device="卧室灯">
            <input type="radio" name="light_bedroom" id="light_bedroom_on" onclick="controlDevice(this)">
            <label for="light_bedroom_on">开启</label>
            <input type="radio" name="light_bedroom" id="light_bedroom_off" onclick="controlDevice(this)">
            <label for="light_bedroom_off">关闭</label>
          </div>

          <div class="control-group" data-device="客厅灯">
            <input type="radio" name="light_livingroom" id="light_livingroom_on" onclick="controlDevice(this)">
            <label for="light_livingroom_on">开启</label>
            <input type="radio" name="light_livingroom" id="light_livingroom_off" onclick="controlDevice(this)">
            <label for="light_livingroom_off">关闭</label>
          </div>

          <div class="control-group" data-device="空气净化器">
            <input type="radio" name="air_purifier" id="air_purifier_on" onclick="controlDevice(this)">
            <label for="air_purifier_on">开启</label>
            <input type="radio" name="air_purifier" id="air_purifier_off" onclick="controlDevice(this)">
            <label for="air_purifier_off">关闭</label>
          </div>

          <!-- Modbus设备 -->
          <div class="control-group" data-device="空调开关">
            <input type="radio" name="air_switch" id="air_switch_on" onclick="controlDevice(this)">
            <label for="air_switch_on">开启</label>
            <input type="radio" name="air_switch" id="air_switch_off" onclick="controlDevice(this)">
            <label for="air_switch_off">关闭</label>
          </div>

          <div class="control-group" data-device="加湿器">
            <input type="radio" name="humidifier" id="humidifier_on" onclick="controlDevice(this)">
            <label for="humidifier_on">开启</label>
            <input type="radio" name="humidifier" id="humidifier_off" onclick="controlDevice(this)">
            <label for="humidifier_off">关闭</label>
          </div>

          <div class="control-group" data-device="窗帘">
            <input type="radio" name="curtain" id="curtain_on" onclick="controlDevice(this)">
            <label for="curtain_on">开启</label>
            <input type="radio" name="curtain" id="curtain_off" onclick="controlDevice(this)">
            <label for="curtain_off">关闭</label>
          </div>

          <div class="control-group" data-device="扫地机器人">
            <input type="radio" name="robot_vacuum" id="robot_vacuum_on" onclick="controlDevice(this)">
            <label for="robot_vacuum_on">开启</label>
            <input type="radio" name="robot_vacuum" id="robot_vacuum_off" onclick="controlDevice(this)">
            <label for="robot_vacuum_off">关闭</label>
          </div>

          <div class="control-group" data-device="洗衣机">
            <input type="radio" name="washing_machine" id="washing_machine_on" onclick="controlDevice(this)">
            <label for="washing_machine_on">开启</label>
            <input type="radio" name="washing_machine" id="washing_machine_off" onclick="controlDevice(this)">
            <label for="washing_machine_off">关闭</label>
          </div>
        </form>
      </div>
    </div>
</body>

</html>